package com.kuang.controller;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.kuang.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/json")
public class JsonController {

    @ResponseBody
    @RequestMapping("/j1")
    public String json01() throws JsonProcessingException {
        User user = new User("1","yutao","男");

        ObjectMapper mapper = new ObjectMapper();
        String s = mapper.writeValueAsString(user);

        return s;



    }


}
